CREATE TABLE [IdentityDemo]( [SrNumber] [int] Primary Key IDENTITY(1,1) NOT NULL, [Name] [varchar](10) NOT NULL, [Age] [int] NULL, [City] [varchar](5) NULL ); CREATE TABLE [Pupil]( [RollNum] [int] NULL, [Name] [char](20) NOT NULL, [Email] [varchar](20) NULL, [Age] [int] NOT NULL, [Gender] [char](10) NULL, [Grade] [char](20) NOT NULL, [Fee] [decimal](6, 2) NOT NULL, [DOB] [date] NOT NULL, [CreatedDate] [datetime] NULL DEFAULT (getdate()) ) --Syntax -- Select col1, col2 from TableName Select Name, Age from IdentityDemo -- * Represents all columns select * from IdentityDemo --Specific columns select Name,Age from IdentityDemo --Here StudentName is alias of Name column --Here StudentAge is alias of Age column select Name as StudentName, Age as StudentAge from IdentityDemo -- Top N caluse select * from IdentityDemo select top 1 * from IdentityDemo select Name, Age from IdentityDemo select top 1 Name, Age from IdentityDemo --No Top N and top 5 records select Name, Age from IdentityDemo select top 5 Name as StudentName, Age as StudentAge from IdentityDemo --All data from Pupil table Select * from Pupil --Only LKG students data. Here filter criterial lying with Grade column Select * from Pupil Where Grade = 'LKG'; Select Name, Email, Age, Gender, Grade from Pupil Where Grade = 'LKG'; --Students with Age 5 select * from Pupil where Age = 5 --Here Age is a numeric column --Numeric columns can have all arithmetic operators used in the filter criteria. -- = Equals To -- > Greater Than -- < Less Than -- >= Greater Than or Equals to -- <= Less Than or Equals to -- <> Not Equals to --Get Students records whose age is greater than 6 years. select * from Pupil where Age > 6 --We can use more than one column in the filter criteria. --Get LKG students data whose age is less than 7 Years. Select * from Pupil where Grade = 'LKG' and Age < 7